//
//  dataSend-receiveViewController.m
//  MMWMiotLinkDemo
//
//  Created by xuqijin on 16/03/2018.
//  Copyright © 2018 HGG. All rights reserved.
//

#import "dataSend-receiveViewController.h"
#import "vspOperation.h"

@interface dataSend_receiveViewController ()
@property (strong, nonatomic) IBOutlet UITextView *sendDataText;

@property (strong, nonatomic) IBOutlet UITextView *receiveDataText;

@end

@implementation dataSend_receiveViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveData:) name:@"deviceData" object:nil];
}
- (IBAction)sendDataAction:(id)sender {
//    self.sendDataText.text = @"F1F1030101057E";
    [[vspOperation shareInstance] sendCommand:self.sendDataText.text ];
}
- (void)receiveData:(NSNotification *)noti
{
    NSDictionary * dataDic = noti.userInfo;
    __weak typeof(self)weakSelf = self;
    dispatch_async(dispatch_get_main_queue(), ^{
        __strong typeof(weakSelf)strongSelf = weakSelf;
        strongSelf.receiveDataText.text = dataDic[@"Older"];
    });
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
